package com.example.demo.service;

import com.example.demo.core.ElasticsearchOperationUtils;
import com.example.demo.domain.OrderSyncRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Shanks
 * @date 2020-05-17
 */
@Service
public class OrderSyncService {

    @Resource
    private ElasticsearchOperationUtils elasticsearchOperationUtils;

    public boolean upsert(OrderSyncRequest request) {
        return elasticsearchOperationUtils.upsertOneSyncById("order", "", request, request.getOrderNo());
    }

    public boolean upsertBatch(List<OrderSyncRequest> list) {
        return elasticsearchOperationUtils.insertBulkSyncData("order", "_doc", list, "orderNo");
    }
}